/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.rantipin.persistence;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author rantipin
 */
@Entity
@Table(name = "scratch")
@NamedQueries({@NamedQuery(name = "Scratch.findAll", query = "SELECT s FROM Scratch s"), @NamedQuery(name = "Scratch.findById", query = "SELECT s FROM Scratch s WHERE s.id = :id"), @NamedQuery(name = "Scratch.findByName", query = "SELECT s FROM Scratch s WHERE s.name = :name"), @NamedQuery(name = "Scratch.findByWidthPixel", query = "SELECT s FROM Scratch s WHERE s.widthPixel = :widthPixel"), @NamedQuery(name = "Scratch.findByWidthMeter", query = "SELECT s FROM Scratch s WHERE s.widthMeter = :widthMeter"), @NamedQuery(name = "Scratch.findByDescription", query = "SELECT s FROM Scratch s WHERE s.description = :description")})
public class Scratch implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "name")
    private String name;
    @Column(name = "width_pixel")
    private BigInteger widthPixel;
    @Column(name = "width_meter")
    private Double widthMeter;
    @Column(name = "description")
    private String description;
    @Lob
    @Column(name = "photo_real")
    private byte[] photoReal;
    @Lob
    @Column(name = "photo_processing")
    private byte[] photoProcessing;
    @JoinColumn(name = "id_sample", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Sample idSample;

    public Scratch() {
    }

    public Scratch(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigInteger getWidthPixel() {
        return widthPixel;
    }

    public void setWidthPixel(BigInteger widthPixel) {
        this.widthPixel = widthPixel;
    }

    public Double getWidthMeter() {
        return widthMeter;
    }

    public void setWidthMeter(Double widthMeter) {
        this.widthMeter = widthMeter;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public byte[] getPhotoReal() {
        return photoReal;
    }

    public void setPhotoReal(byte[] photoReal) {
        this.photoReal = photoReal;
    }

    public byte[] getPhotoProcessing() {
        return photoProcessing;
    }

    public void setPhotoProcessing(byte[] photoProcessing) {
        this.photoProcessing = photoProcessing;
    }

    public Sample getIdSample() {
        return idSample;
    }

    public void setIdSample(Sample idSample) {
        this.idSample = idSample;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Scratch)) {
            return false;
        }
        Scratch other = (Scratch) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ru.rantipin.persistence.Scratch[id=" + id + "]";
    }

}
